/*
 * TestUnitOfWork.java
 *
 * Copyright (c)2007, HeadCase Humanufacturing, Inc. All rights reserved.
 * CONFIDENTIAL AND PROPRIETARY. NOT FOR DISTRIBUTION.
 */

package com.headcaselabs.work;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class TestUnitOfWork extends UnitOfWork {

  private final static Log log_ =
    LogFactory.getLog(TestUnitOfWork.class.getName());
    int num; 
    public TestUnitOfWork(int num, String id, long max_time) {
            this.num = num;
            this.id = id;
            this.max_time = max_time;
    }

    @Override
    public Integer call() {
      int i;
      System.out.println("Started task...."+id);
      OuterLoop: for (i = 2; i <= num; i++) {
        for (int j = 2; j < i; j++) {
                if (interrupted) {
                        break;
                }
	        if (i % j == 0) {
	          continue OuterLoop;
	        }
        }
      }
      //TODO: this section needs to be in pretty much every task!
      if (!interrupted) {
      	postProcess();
      }
      log_.info("Finished postProcessing task");
      return i;
    }

    @Override
    public void cleanup() {
       
    }

    @Override
    public void store() {
       
    }

}
